<div class="account-wrapper" ng-controller="communityEditCtrl">
    <div class="account-body">
        <h4>编辑小区</h4>

        <form class="form account-form">

            <div class="form-group">
                <label class="control-label" for="textinput">小区名称：</label>
                <input class="form-control" ng-model="community.communityName" required tabindex="4">
            </div>
            <div class="form-group">
                <label class="control-label" for="textinput">小区地址：</label>
                <input class="form-control" ng-model="community.communityAddress" required tabindex="5">
            </div>
            <div class="form-group">
                <label class="control-label">生效日期:</label>

                <!--<div class="col-md-2">-->
                    <input type="text" id="effective" data-provide="datepicker"
                           class="form-control datepicker" data-date-format="yyyy-mm-dd"
                           ng-model="community.dateEffective" required>
                <!--</div>-->
            </div>
            <div class="form-group">
                <label class="control-label" for="textinput">户数：</label>
                <input class="form-control" ng-model="community.households" required tabindex="5">
            </div>
            <div class="form-group">
                <label class="control-label" for="textinput">邮编：</label>
                <input class="form-control" ng-model="community.communityPostCode" required tabindex="5">
            </div>
            <div class="form-group">
                <label class="control-label" for="textinput">常用电话：</label>

                <div ng-repeat="m in community.phoneList">
                    <input ng-model="m.name" data-provide="typeahead"/><input ng-model="m.phoneNo"
                                                                              data-provide="typeahead"/>
                    <button ng-click="deletePhoneNo($index)">删除</button>
                </div>
                <button ng-click="addPhoneNo()">添加</button>
            </div>
            <div class="form-group">
                <label class="control-label" for="textinput">是否显示单元号开关：</label>
                <input type="checkbox" ng-model="community.unitSwitch" ng-checked="community.unitSwitch">
            </div>

            <div class="form-group">

                <label class="control-label" for="textinput">小区logo:</label>

                <input type="file" id="pict"
                       onchange="angular.element(this).scope().selectFile(this.files)" accept="image/*">
                <img id="logo" style="width: 200px" ng-src="{{community.communityLogo}}">
            </div>

            <div class="form-group">
                <a ng-click="gotoCommunityListPage()" class="btn btn-xs btn-primary">取消</a>
                <a ng-click="updateCommunity()" class="btn btn-xs btn-primary">确认</a>
            </div>
        </form>
    </div>
</div>

<script>


    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    var fromDate = $('#effective').datepicker().on('changeDate', function (ev) {
        //alert(ev.date.format('yyyy-MM-dd'));
        //$scope.startDate=ev.date.format('yyyy-MM-dd');
        $("#effective").val(ev.date.format('yyyy-MM-dd'));
    });

//    var toDate = $('#endDate').datepicker().on('changeDate', function (ev) {
//        // alert(ev.date.format('yyyy-MM-dd'));
//        //$scope.endDate=ev.date.format('yyyy-MM-dd');
//        $("#endDate").val(ev.date.format('yyyy-MM-dd'));
//    });

</script>